
rm(list = ls()) #清空内存函数
library(RMySQL)
con <- dbConnect(MySQL(),host="192.168.3.139",
                 dbname="niek_160906",user="niek",password="FbWf8AKC")  
dbSendQuery(con,'set names utf8')

# devtools::install_git('https://git.oschina.net/seifer_earth/house_price.git')
# library(house.price)
# count_POI(con=con)

#基期及城市设定
year_base<-2015
date_base_begin<-24181
date_base_end<-24192
date_base<-24133  #基点为100的基期设定为2011年1月
city_code<-'qd'   #城市设定为青岛
pty<-11           #产品类型
source('yangsj/base_compute_sale.R')

#参数设定
minmum_city<-30   #城市最小样本量设定
minmum_dist<-30   #行政区最小样本量设定

#目标城市集合
# city_lt<-dbGetQuery(con,"select distinct city_code from ha_price")
# city.list<-city_lt$city_code

# city.list<-c('bj','sh','gz','cq','zz','nj','wh','su','hz','cd','hb','sz','dg','cs',
#              'fs','hf','km','sj','qd','xm','sy','jn','xa','wx','nn','dl','zh','nb',
#              'huizhou','lz','fz','cc','hk','gy','zhongshan','ty','cz','wf','nc','yt',
#              'wl','lf','zb','jx','nt','ly','jm','wz','hh','yz','jh','liuzhou','jl',
#              'zhuzhou','bt','qz','ts','tz','sx','my','sanya','hd','st','wuhu','xy',
#              'gl','zj','dq','as','chenzhou','chizhou','dd','dy','jiaozuo','jz','jc',
#              'longyan','mas','ny','pt','qj','xiangtan','xc','yanbian','yq','zhangzhou',
#              'tj','bengbu','hy','danzhou','qh')
 
city.list<-c('hz')

#保存每月样本量不足的城市名
city_blank<-as.data.frame(rep(0,666))
len_blank<-0

for (zz in 1:length(city.list)) {
    
    city_code<-city.list[zz]
    source('yangsj/city+dist_sale_tj2.R')
}

library(xlsx)
write.xlsx(city_blank[1:len_blank,],paste0("/home/yangsj/mnt/city_blank/样本量不足城市",pty,".xlsx"),"Sheet1",row.names = FALSE)

dbDisconnect(con)



